﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using MyAMS.WebServer.ActionFilter;

namespace MyAMS.WebServer
{
    /// <summary>
    /// 模块
    /// </summary>
    public interface IModule
    {
        /// <summary>
        /// 获取功能名称
        /// </summary>
        string Name { get; }

        /// <summary>
        /// 获取一个值, 该值指示当前实例是否已被加载
        /// </summary>
        bool IsLoaded { get; }

        /// <summary>
        /// 加载时被调用
        /// </summary>
        void OnLoading();

        /// <summary>
        /// 加载被忽略的路由
        /// </summary>
        /// <param name="routes"></param>
        void LoadIgnoredRoutes(RouteCollection routes);

        /// <summary>
        /// 加载路由
        /// </summary>
        /// <param name="routes"></param>
        void LoadRoutes(RouteCollection routes);

        /// <summary>
        /// 加载模糊路由
        /// </summary>
        /// <param name="routes"></param>
        void LoadCatchAllRoutes(RouteCollection routes);

        /// <summary>
        /// 加载视图引擎
        /// </summary>
        /// <param name="viewEngines">视图引擎</param>
        void LoadViewEngines(ViewEngineCollection viewEngines);

        /// <summary>
        /// 加载动作过滤器
        /// </summary>
        /// <param name="filterRegistry"></param>
        void LoadActionFilters(IActionFilterRegistry filterRegistry);

        /// <summary>
        /// 加载模型绑定器
        /// </summary>
        /// <param name="modelBinders"></param>
        void LoadModelBinders(ModelBinderDictionary modelBinders);

        /// <summary>
        /// 加载完毕后被调用
        /// </summary>
        void OnLoaded();

        /// <summary>
        /// 卸载路由注册
        /// </summary>
        /// <param name="routes"></param>
        void UnLoadRoutes(RouteCollection routes);

        /// <summary>
        /// 卸载
        /// </summary>
        void UnLoad();
    }
}
